package hyrpt

class CoherenceStatisticsController {
    def dynamicQueryService
    def coherenceStatistics(){
        def pageCurrent = params.pageCurrent ? Integer.parseInt(params.pageCurrent) : 1
        def pageSize = params.pageSize ? Integer.parseInt(params.pageSize) : 10
        params.startno = (pageSize * (pageCurrent - 1)) + 1
        params.endno = pageSize * pageCurrent
        def tableHeadList=[]
        def coherenceStatistics=[]
        def pageSizeList = [10,20,50,100]
        def totalCount =0
        def coherenceStatisticsSumQty=[]
        List<Integer> list=new ArrayList<Integer>();
        if(params.EXPORT_CONTENT_NAME=='Excel'){
            params.SYS_QUERY_NAME = 'coherenceStatistics'
            coherenceStatistics = dynamicQueryService.queryForList(params)
            if (coherenceStatistics.size() > 0) {
                tableHeadList = coherenceStatistics[0].keySet()
            }
            params.SYS_QUERY_NAME = 'coherenceStatisticsSumQty'
            coherenceStatisticsSumQty = dynamicQueryService.queryForList(params)

        }
        println(coherenceStatisticsSumQty)

        [startno:params.startno?:'',
         endno:params.endno?:'',
         pageSize     : pageSize,
         totalCount: totalCount,
         pageSizeList: pageSizeList,
         pageCurrent:pageCurrent,
         tableHeadList:tableHeadList,
         coherenceStatistics:coherenceStatistics,
         coherenceStatisticsSumQty:coherenceStatisticsSumQty,
         startTime:params.startTime,
         endTime:params.endTime,
         woId: params.woId ?: '',
         partName: params.partName ?: ''

        ]
    }
}
